export default {
	gotReds:store=>store.gotReds,
	conversations:(store,...arg)=>{
		if(!store.conversationMap){return []}
		const tops = []
		const list = [];
		for(let key in store.conversationMap){
			const temp = store.conversationMap[key]
			if(temp.isTop){
				tops.push(temp)
			}else{
				list.push(temp)
			}
		}
		
		list.sort((p,n)=>!!p.lastTime&&!!n.lastTime&&n.lastTime-p.lastTime);
		return tops.concat(list);
	},
	unread:(state,{conversations})=>{
		const sum = conversations.reduce((res,{unread,isMute})=>isMute?res:(res+unread),0)
		if(!!sum){
			uni.setTabBarBadge({
				index:0,
				text:`${sum}`
			})
		}else{
			uni.removeTabBarBadge({
				index:0
			})
		}
		return sum
	},
	history:store=>store.history,
	channel:store=>store.channel,
	online:store=>store.online
}
